/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nurdrobotics;

/**
 *
 * @author hpadmin
 */
public class BallCounter {

    // Need to check where to put upper limit switch with new shooter

    private static int numBalls = 0;

    public static void teleopUpdate() {
        // check state of inc and dec buttons and set counter
        if (DriverStick.incrementButton.RisingEdge()) {
            BallCounter.increment();
        } else if (DriverStick.decrementButton.RisingEdge()) {
            BallCounter.decrement();
        }
    }

    /*
     * set the counter and update the dashboard
     */
    private static void setCount(int count) {
        if (count < 0) {
            count = 0;
        }
        numBalls = count;
        Dashboard.setBallCounterStatus("" + numBalls);
    }

    /*
     * reset the ball counter to 0
     */
    public static void reset() {
        setCount(0);
    }

    /*
     * increment the ball counter
     */
    public static void increment() {
        setCount(numBalls + 1);
    }

    /*
     * decrement the ball counter
     */
    public static void decrement() {
        setCount(numBalls - 1);
    }

    public static int get() {
        return numBalls;
    }
}
